/*********************************************************
 * Cameron Hilton
 * CS362_400
 * 
 * Test to see if steward card has desired outcome in cardEffect() function
 ********************************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus);

int main() {
    
    int seed = 1000;
    int numPlayer = 2;
    int bonus = 0;
    
	struct gameState state;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	memset(&state, 23, sizeof(struct gameState)); // reset game state
	initializeGame(numPlayer, k, seed, &state);

	state.whoseTurn = 0;
	state.hand[0][0] = steward; // ensure steward is in player's hand

	state.handCount[0] = 5;
	state.coins = 0;

	printf("Testing return value\n");
	assert(cardEffect(steward, 1, 0, 0, &state, 0, &bonus) == 0);

	memset(&state, 23, sizeof(struct gameState)); // reset game state
	initializeGame(numPlayer, k, seed, &state);
	state.handCount[0] = 5;
	state.coins = 0;

	printf("Testing hand and coin count for choice1 = 1\n");
	cardEffect(steward, 1, 2, 3, &state, 0, &bonus);
	assert(state.handCount[0] == 6);
	assert(state.coins == 0);

	memset(&state, 23, sizeof(struct gameState)); // reset game state
	initializeGame(numPlayer, k, seed, &state);
	state.handCount[0] = 5;
	state.coins = 0;

	printf("Testing hand and coin count for choice1 = 2\n");
	cardEffect(steward, 2, 2, 3, &state, 0, &bonus);
	assert(state.handCount[0] == 4);
	assert(state.coins == 2);

	memset(&state, 23, sizeof(struct gameState)); // reset game state
	initializeGame(numPlayer, k, seed, &state);
	state.handCount[0] = 5;
	state.coins = 0;

	printf("Testing hand and coin count for choice1 = 3\n");
	cardEffect(steward, 3, 2, 3, &state, 0, &bonus);
	assert(state.handCount[0] == 2);
	assert(state.coins == 0);

    printf("All tests passed!\n");

    return 0;
}